\(\int \frac {1}{a+b \cot ^2(c+d x)} \, dx\) [5]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [B] (verification not implemented)
   Maxima [A] (verification not implemented)
   Giac [A] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 14, antiderivative size = 49 \[ \int \frac {1}{a+b \cot ^2(c+d x)} \, dx=\frac {x}{a-b}+\frac {\sqrt {b} \arctan \left (\frac {\sqrt {b} \cot (c+d x)}{\sqrt {a}}\right )}{\sqrt {a} (a-b) d} \]

[Out]

x/(a-b)+arctan(cot(d*x+c)*b^(1/2)/a^(1/2))*b^(1/2)/(a-b)/d/a^(1/2)

Rubi [A] (verified)

Time = 0.09 (sec) , antiderivative size = 49, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 3, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.214, Rules used = {3741, 3756, 211} \[ \int \frac {1}{a+b \cot ^2(c+d x)} \, dx=\frac {\sqrt {b} \arctan \left (\frac {\sqrt {b} \cot (c+d x)}{\sqrt {a}}\right )}{\sqrt {a} d (a-b)}+\frac {x}{a-b} \]

[In]

Int[(a + b*Cot[c + d*x]^2)^(-1),x]

[Out]

x/(a - b) + (Sqrt[b]*ArcTan[(Sqrt[b]*Cot[c + d*x])/Sqrt[a]])/(Sqrt[a]*(a - b)*d)

Rule 211

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(Rt[a/b, 2]/a)*ArcTan[x/Rt[a/b, 2]], x] /; FreeQ[{a, b}, x]
&& PosQ[a/b]

Rule 3741

Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)]^2)^(-1), x_Symbol] :> Simp[x/(a - b), x] - Dist[b/(a - b), Int[Sec[e
 + f*x]^2/(a + b*Tan[e + f*x]^2), x], x] /; FreeQ[{a, b, e, f}, x] && NeQ[a, b]

Rule 3756

Int[sec[(e_.) + (f_.)*(x_)]^(m_)*((a_) + (b_.)*((c_.)*tan[(e_.) + (f_.)*(x_)])^(n_))^(p_.), x_Symbol] :> With[
{ff = FreeFactors[Tan[e + f*x], x]}, Dist[ff/(c^(m - 1)*f), Subst[Int[(c^2 + ff^2*x^2)^(m/2 - 1)*(a + b*(ff*x)
^n)^p, x], x, c*(Tan[e + f*x]/ff)], x]] /; FreeQ[{a, b, c, e, f, n, p}, x] && IntegerQ[m/2] && (IntegersQ[n, p
] || IGtQ[m, 0] || IGtQ[p, 0] || EqQ[n^2, 4] || EqQ[n^2, 16])

Rubi steps \begin{align*} \text {integral}& = \frac {x}{a-b}-\frac {b \int \frac {\csc ^2(c+d x)}{a+b \cot ^2(c+d x)} \, dx}{a-b} \\ & = \frac {x}{a-b}+\frac {b \text {Subst}\left (\int \frac {1}{a+b x^2} \, dx,x,\cot (c+d x)\right )}{(a-b) d} \\ & = \frac {x}{a-b}+\frac {\sqrt {b} \arctan \left (\frac {\sqrt {b} \cot (c+d x)}{\sqrt {a}}\right )}{\sqrt {a} (a-b) d} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.07 (sec) , antiderivative size = 49, normalized size of antiderivative = 1.00 \[ \int \frac {1}{a+b \cot ^2(c+d x)} \, dx=\frac {\arctan (\tan (c+d x))-\frac {\sqrt {b} \arctan \left (\frac {\sqrt {a} \tan (c+d x)}{\sqrt {b}}\right )}{\sqrt {a}}}{a d-b d} \]

[In]

Integrate[(a + b*Cot[c + d*x]^2)^(-1),x]

[Out]

(ArcTan[Tan[c + d*x]] - (Sqrt[b]*ArcTan[(Sqrt[a]*Tan[c + d*x])/Sqrt[b]])/Sqrt[a])/(a*d - b*d)

Maple [A] (verified)

Time = 0.08 (sec) , antiderivative size = 56, normalized size of antiderivative = 1.14

method result size
derivativedivides \(\frac {-\frac {\frac {\pi }{2}-\operatorname {arccot}\left (\cot \left (d x +c \right )\right )}{a -b}+\frac {b \arctan \left (\frac {b \cot \left (d x +c \right )}{\sqrt {a b}}\right )}{\left (a -b \right ) \sqrt {a b}}}{d}\) \(56\)
default \(\frac {-\frac {\frac {\pi }{2}-\operatorname {arccot}\left (\cot \left (d x +c \right )\right )}{a -b}+\frac {b \arctan \left (\frac {b \cot \left (d x +c \right )}{\sqrt {a b}}\right )}{\left (a -b \right ) \sqrt {a b}}}{d}\) \(56\)
risch \(\frac {x}{a -b}+\frac {\sqrt {-a b}\, \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}-\frac {2 i \sqrt {-a b}+a +b}{a -b}\right )}{2 a \left (a -b \right ) d}-\frac {\sqrt {-a b}\, \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+\frac {2 i \sqrt {-a b}-a -b}{a -b}\right )}{2 a \left (a -b \right ) d}\) \(120\)

[In]

int(1/(a+b*cot(d*x+c)^2),x,method=_RETURNVERBOSE)

[Out]

1/d*(-1/(a-b)*(1/2*Pi-arccot(cot(d*x+c)))+b/(a-b)/(a*b)^(1/2)*arctan(b*cot(d*x+c)/(a*b)^(1/2)))

Fricas [A] (verification not implemented)

none

Time = 0.28 (sec) , antiderivative size = 252, normalized size of antiderivative = 5.14 \[ \int \frac {1}{a+b \cot ^2(c+d x)} \, dx=\left [\frac {4 \, d x - \sqrt {-\frac {b}{a}} \log \left (\frac {{\left (a^{2} + 6 \, a b + b^{2}\right )} \cos \left (2 \, d x + 2 \, c\right )^{2} + 4 \, {\left (a^{2} - a b - {\left (a^{2} + a b\right )} \cos \left (2 \, d x + 2 \, c\right )\right )} \sqrt {-\frac {b}{a}} \sin \left (2 \, d x + 2 \, c\right ) + a^{2} - 6 \, a b + b^{2} - 2 \, {\left (a^{2} - b^{2}\right )} \cos \left (2 \, d x + 2 \, c\right )}{{\left (a^{2} - 2 \, a b + b^{2}\right )} \cos \left (2 \, d x + 2 \, c\right )^{2} + a^{2} + 2 \, a b + b^{2} - 2 \, {\left (a^{2} - b^{2}\right )} \cos \left (2 \, d x + 2 \, c\right )}\right )}{4 \, {\left (a - b\right )} d}, \frac {2 \, d x + \sqrt {\frac {b}{a}} \arctan \left (\frac {{\left ({\left (a + b\right )} \cos \left (2 \, d x + 2 \, c\right ) - a + b\right )} \sqrt {\frac {b}{a}}}{2 \, b \sin \left (2 \, d x + 2 \, c\right )}\right )}{2 \, {\left (a - b\right )} d}\right ] \]

[In]

integrate(1/(a+b*cot(d*x+c)^2),x, algorithm="fricas")

[Out]

[1/4*(4*d*x - sqrt(-b/a)*log(((a^2 + 6*a*b + b^2)*cos(2*d*x + 2*c)^2 + 4*(a^2 - a*b - (a^2 + a*b)*cos(2*d*x +
2*c))*sqrt(-b/a)*sin(2*d*x + 2*c) + a^2 - 6*a*b + b^2 - 2*(a^2 - b^2)*cos(2*d*x + 2*c))/((a^2 - 2*a*b + b^2)*c
os(2*d*x + 2*c)^2 + a^2 + 2*a*b + b^2 - 2*(a^2 - b^2)*cos(2*d*x + 2*c))))/((a - b)*d), 1/2*(2*d*x + sqrt(b/a)*
arctan(1/2*((a + b)*cos(2*d*x + 2*c) - a + b)*sqrt(b/a)/(b*sin(2*d*x + 2*c))))/((a - b)*d)]

Sympy [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 238 vs. \(2 (37) = 74\).

Time = 0.74 (sec) , antiderivative size = 238, normalized size of antiderivative = 4.86 \[ \int \frac {1}{a+b \cot ^2(c+d x)} \, dx=\begin {cases} \frac {\tilde {\infty } x}{\cot ^{2}{\left (c \right )}} & \text {for}\: a = 0 \wedge b = 0 \wedge d = 0 \\\frac {x}{a} & \text {for}\: b = 0 \\\frac {- x + \frac {1}{d \cot {\left (c + d x \right )}}}{b} & \text {for}\: a = 0 \\\frac {d x \cot ^{2}{\left (c + d x \right )}}{2 b d \cot ^{2}{\left (c + d x \right )} + 2 b d} + \frac {d x}{2 b d \cot ^{2}{\left (c + d x \right )} + 2 b d} - \frac {\cot {\left (c + d x \right )}}{2 b d \cot ^{2}{\left (c + d x \right )} + 2 b d} & \text {for}\: a = b \\\frac {x}{a + b \cot ^{2}{\left (c \right )}} & \text {for}\: d = 0 \\\frac {2 d x \sqrt {- \frac {a}{b}}}{2 a d \sqrt {- \frac {a}{b}} - 2 b d \sqrt {- \frac {a}{b}}} + \frac {\log {\left (- \sqrt {- \frac {a}{b}} + \cot {\left (c + d x \right )} \right )}}{2 a d \sqrt {- \frac {a}{b}} - 2 b d \sqrt {- \frac {a}{b}}} - \frac {\log {\left (\sqrt {- \frac {a}{b}} + \cot {\left (c + d x \right )} \right )}}{2 a d \sqrt {- \frac {a}{b}} - 2 b d \sqrt {- \frac {a}{b}}} & \text {otherwise} \end {cases} \]

[In]

integrate(1/(a+b*cot(d*x+c)**2),x)

[Out]

Piecewise((zoo*x/cot(c)**2, Eq(a, 0) & Eq(b, 0) & Eq(d, 0)), (x/a, Eq(b, 0)), ((-x + 1/(d*cot(c + d*x)))/b, Eq
(a, 0)), (d*x*cot(c + d*x)**2/(2*b*d*cot(c + d*x)**2 + 2*b*d) + d*x/(2*b*d*cot(c + d*x)**2 + 2*b*d) - cot(c +
d*x)/(2*b*d*cot(c + d*x)**2 + 2*b*d), Eq(a, b)), (x/(a + b*cot(c)**2), Eq(d, 0)), (2*d*x*sqrt(-a/b)/(2*a*d*sqr
t(-a/b) - 2*b*d*sqrt(-a/b)) + log(-sqrt(-a/b) + cot(c + d*x))/(2*a*d*sqrt(-a/b) - 2*b*d*sqrt(-a/b)) - log(sqrt
(-a/b) + cot(c + d*x))/(2*a*d*sqrt(-a/b) - 2*b*d*sqrt(-a/b)), True))

Maxima [A] (verification not implemented)

none

Time = 0.32 (sec) , antiderivative size = 48, normalized size of antiderivative = 0.98 \[ \int \frac {1}{a+b \cot ^2(c+d x)} \, dx=-\frac {\frac {b \arctan \left (\frac {a \tan \left (d x + c\right )}{\sqrt {a b}}\right )}{\sqrt {a b} {\left (a - b\right )}} - \frac {d x + c}{a - b}}{d} \]

[In]

integrate(1/(a+b*cot(d*x+c)^2),x, algorithm="maxima")

[Out]

-(b*arctan(a*tan(d*x + c)/sqrt(a*b))/(sqrt(a*b)*(a - b)) - (d*x + c)/(a - b))/d

Giac [A] (verification not implemented)

none

Time = 0.30 (sec) , antiderivative size = 65, normalized size of antiderivative = 1.33 \[ \int \frac {1}{a+b \cot ^2(c+d x)} \, dx=-\frac {\frac {{\left (\pi \left \lfloor \frac {d x + c}{\pi } + \frac {1}{2} \right \rfloor \mathrm {sgn}\left (a\right ) + \arctan \left (\frac {a \tan \left (d x + c\right )}{\sqrt {a b}}\right )\right )} b}{\sqrt {a b} {\left (a - b\right )}} - \frac {d x + c}{a - b}}{d} \]

[In]

integrate(1/(a+b*cot(d*x+c)^2),x, algorithm="giac")

[Out]

-((pi*floor((d*x + c)/pi + 1/2)*sgn(a) + arctan(a*tan(d*x + c)/sqrt(a*b)))*b/(sqrt(a*b)*(a - b)) - (d*x + c)/(
a - b))/d

Mupad [B] (verification not implemented)

Time = 0.12 (sec) , antiderivative size = 41, normalized size of antiderivative = 0.84 \[ \int \frac {1}{a+b \cot ^2(c+d x)} \, dx=\frac {x}{a-b}+\frac {b\,\mathrm {atan}\left (\frac {b\,\mathrm {cot}\left (c+d\,x\right )}{\sqrt {a\,b}}\right )}{d\,\sqrt {a\,b}\,\left (a-b\right )} \]

[In]

int(1/(a + b*cot(c + d*x)^2),x)

[Out]

x/(a - b) + (b*atan((b*cot(c + d*x))/(a*b)^(1/2)))/(d*(a*b)^(1/2)*(a - b))